import React from "react";
import axios from "axios";

export default function App() {
  const getStudents = () => {
    axios
      .get("http://localhost:3000/api1/students")
      .then((res) => {
        console.log("成功", res.data);
      })
      .catch((err) => {
        console.log("失败", err);
      });
  };
  const getCars = () => {
    axios
      .get("http://localhost:3000/api2/cars")
      .then((res) => {
        console.log("成功", res.data);
      })
      .catch((err) => {
        console.log("失败", err);
      });
  };
  return (
    <div>
      <button onClick={getStudents}>点击获取server1的数据</button>
      <button onClick={getCars}>点击获取server1的数据</button>
    </div>
  );
}
